﻿using System.Collections.Generic;
using KMF.Common;

namespace KMF.DAL
{
    public partial class BannerImageDb
    {
        /// <summary>
        /// Lấy về danh sách theo BannerId
        /// </summary>
        /// <param name="bannerId"></param>
        /// <returns></returns>
        public static List<BannerImageDto> GetAllByBannerId(string bannerId)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_BannerImage_GetAllByBannerId");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@BannerId", bannerId));
                return dao.GetDTOList<BannerImageDto>(ref command);
            }
            finally
            {
                command.Connection.Close();
            }
        }

        /// <summary>
        /// Xóa ảnh banner theo BannerId
        /// </summary>
        /// <param name="bannerId"></param>
        /// <returns></returns>
        public static int DeleteByBannerId(string bannerId)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_BannerImage_DeleteByBannerId");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@BannerId", bannerId));
                return command.ExecuteNonQuery();
            }
            finally
            {
                command.Connection.Close();
            }
        }
    }
}
